/**
 * @Author: 小狐
 * @Date: 2021/11/29 17:28
 * @Describe 主动去学习
 *
 */
package service

import (
	"context"
	"dubbo_maoyan/api/api"
	"event/dao"
)

type EventProvider struct {
	api.UnimplementedEventServer
}

func(e *EventProvider) SendEvent(ctx context.Context,request *api.EventRequest) (*api.EventListResponse,error)  {

	eventList, _ := dao.EventDao.SendEvent(ctx, request)

	 eventListResponse := &api.EventListResponse{}

	for _,event := range eventList{
		response := &api.EventResponse{
			EventId:     event.EventId,
			EventImg:    event.EventImg,
			EventName:   event.EventName,
			EventType:   event.EventType,
			EventStatus: event.EventStatus,
		}
		eventListResponse.EventResponse = append(eventListResponse.EventResponse,response)
	}
	return eventListResponse, nil

}